package cn.ekuma.epos.datalogic.define.dao.shard;

import cn.ekuma.epos.db.table.shard.I_AddressEntityTable;
import cn.ekuma.epos.db.table.shard.I_PeopleEntityTable;

import com.openbravo.bean.shard.I_PeopleEntity;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;

public class PeopleEntityDAOHelper {
	
	 public static TableDefinition getTable(I_Session s,String tableName){
		 TableDefinition table=AddressEntityDAOHelper.getTable(s, tableName);
	     table.addField( new Field(I_PeopleEntityTable.NAME,Datas.STRING,Formats.STRING));
	     table.addField( new Field(I_PeopleEntityTable.FIRSTNAME,Datas.STRING,Formats.STRING));
	     table.addField( new Field(I_PeopleEntityTable.LASTNAME,Datas.STRING,Formats.STRING));
	     table.addField( new Field(I_PeopleEntityTable.EMAIL,Datas.STRING,Formats.STRING));
	     table.addField( new Field(I_PeopleEntityTable.PHONE,Datas.STRING,Formats.STRING));
	     return table;
	 }

	public static void writeInsertValues(DataWrite dp, I_PeopleEntity obj,int start) throws BasicException {
		AddressEntityDAOHelper.writeInsertValues(dp, obj, start);
		dp.setString(I_AddressEntityTable.ADDRESS_COLUMN_COUNT+start, obj.getName());
		dp.setString(I_AddressEntityTable.ADDRESS_COLUMN_COUNT+start+1, obj.getFirstname());
        dp.setString(I_AddressEntityTable.ADDRESS_COLUMN_COUNT+start+2, obj.getLastname());
        dp.setString(I_AddressEntityTable.ADDRESS_COLUMN_COUNT+start+3, obj.getEmail());
        dp.setString(I_AddressEntityTable.ADDRESS_COLUMN_COUNT+start+4, obj.getPhone());
    }

    public static void readValues(DataRead dr,I_PeopleEntity obj,int start) throws BasicException {
    	AddressEntityDAOHelper.readValues(dr, obj, start);
    	obj.setName(dr.getString(I_AddressEntityTable.ADDRESS_COLUMN_COUNT+start));
    	obj.setFirstname(dr.getString(I_AddressEntityTable.ADDRESS_COLUMN_COUNT+start+1));
    	obj.setLastname(dr.getString(I_AddressEntityTable.ADDRESS_COLUMN_COUNT+start+2));
    	obj.setEmail(dr.getString(I_AddressEntityTable.ADDRESS_COLUMN_COUNT+start+3));
    	obj.setPhone(dr.getString(I_AddressEntityTable.ADDRESS_COLUMN_COUNT+start+4));
    }
	
}
